<?php 

//用函数判断是否是图片

 $str = '45.4.jpg';

function check_img($name){
    //生明一个数组存放是图片的后缀标识
    $img = ['jpg','png','gif','peg'];
    //把数组转换为字符串
    $new = implode('-',$img);
    var_dump($new);
    //把字符串切割为数组
    $arr = explode('.',$name);
    //取到后缀名
    $pattern = end($arr);   //end()函数用来获取最后一个元素
    var_dump($pattern);
    $preg = "/$pattern/";
    // if(in_array($pattern , $img )){
    // 	return true;
    // }else{
    // 	return false;
    // }
    if(preg_match($preg,$new)){
    	return '对的';
    }else{
        return '错的';
    }

}

 var_dump(check_img($str));



//验证身份证号码
// $info = '42058219830518248X';

// $pattern = '/^[1-9]{1}[1-9]{1}[0-9]{1}[\d]{4}[1-9]{1}[\d]{3}[\d\d][\d\d]([\d]{4}|[\d]{3}[A-z]{1})/';

// $res = preg_match($pattern,$info);
// var_dump($res);



//验证邮箱
// $email = '4334@53435sina.net';

// $preg = "/^[a-z1-9]([\w\-\.]*)@[\w]+\.(com|net|cn)(\.com|net|cn)*$/i";

// $res = preg_match($preg,$email);
// var_dump($res);



//去拉钩抓取有效数据
//拉钩官网
// $url = file_get_contents('https://www.lagou.com/jobs/2038966.html?source=home_hot&i=home_hot-0');
// var_dump($url);
//采集标题
// $pattern = '/data-lg-tj-cid=\"\d{7}\"(.+)<span>/';
// $res = preg_match_all($pattern,$url,$job);

// $pattern1 = '/<div class=\"position_main_info\">.*<span class=\"salary fl\">(.)*<\/span>.*<span><!-- <i class=\"experience\"><\/i>&nbsp;  -->(.)*<\/span> \/ <span>(.)*<\/span>/s';

// $pattern1 = '/<span>(.+)<\/span>/';
// $res = preg_match_all($pattern1,$url,$pay);

// var_dump($res);
// // var_dump($job);
// var_dump($pay);








// $url = file_get_contents('https://www.lagou.com');

// // $preg  = "/<div class=\"position_main_info\">.*?<span class=\"salary fl\">(.*?)<\/span>.*?<span><!-- <i class=\"experience\"><\/i>&nbsp;  -->(.*?)<\/span> \/ <span>(.*?)<\/span>.*?<\/div>/s";
                      
                      

// $res = preg_match_all($preg,$url,$c);

// var_dump($res);
// var_dump($c);








 ?>